home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
CAD
/
LISP04.ARJ
/
MULTRIM.LSP
< prev
next >
Wrap
Text File
|
1989-10-20
|
4KB
|
121 lines
; program: MULTIPLETRIM COMMAND - MULTRIM.LSP
;
; description: Trims with selection of many items to trim
; actual selection is by crossing, and items
; must cross a line between the selected crossing
; points. No allowance is made for removal of
; items from the selection set.
;
;
; variables used and their description:
;cs selection set containing cutting edges
;p1 first point for crossing selection (for ts)
;p2 second point for crossing selection (for ts)
;ts election set containing items to be trimmed
;ic item count through trim set (ts)
;te entity name from ts to trim
;ge entity list of te
;et entity type of te
;cp center point of arc or circle
;ra radius of arc or circle
;sa start angle of arc or circle (arbitrarily 0 for circle)
;ea end angle of arc or circle (arbitrarily 2pi for circle)
;dv divisor for number of segments to increment arcs
;ma intermediate angle of arc increment
;ia increment angle for arcs (approximately 10-degrees)
;p3 first point on entity to check for an intersection
;p4 second intersection check point (used with arcs and polylines)
;tp trim point on entity to trim
;e3 vertex of polyline used to get p3
;e4 vertex of polyline used to get p4
;d1,d2,p3 intermediate variables to determine tp on circles
;
;
(defun c:multrim (/ cs p1 p2 ts ic te ge et cp ra sa ea dv ma ia p3 p4 tp e3 e4 d1 d2)
(setvar "CMDECHO" 0)
(princ "\nSelect cutting edges: ")
(setq cs (ssget))
(princ "Select objects to cut: ")
(setq p1 (getpoint "Select first point: ")
p2 (getpoint p1 "Select other point: ")
ts (ssget "c" p1 p2)
ic 0
)
(grdraw p1 p2 -1 1)
(while (setq te (ssname ts ic))
(if (ssmemb te cs)
(setq et nil)
(setq ge (entget te)
et (cdr (assoc 0 ge))
)
)
(cond
((= et "ARC")
(setq cp (cdr (assoc 10 ge))
ra (cdr (assoc 40 ge))
sa (cdr (assoc 50 ge))
ea (cdr (assoc 51 ge))
)
(if (> sa ea)
(setq ea (+ ea pi pi))
)
(if (> 2 (setq dv (fix (/ (- ea sa) (/ pi 18))) ))
(setq dv 2)
)
(setq ma sa
ia (/ (- ea sa) dv)
p4 (polar cp sa ra)
)
(while (< ma ea)
(setq p3 p4
p4 (polar cp (setq ma (+ ma ia)) ra)
)
(if (setq tp (inters p1 p2 p3 p4))
(command "TRIM" cs "" (list te tp) "")
)
)
)
((= et "CIRCLE")
(setq cp (cdr (assoc 10 ge))
ra (cdr (assoc 40 ge))
d1 (* (cos (- (angle p1 cp) (angle p1 p2))) (distance cp p1))
p3 (polar p1 (angle p1 p2) d1)
d2 (distance cp p3)
tp (polar p3 (angle p1 p2) (sqrt (- (* ra ra) (* d2 d2) )))
)
(command "TRIM" cs "" (list te tp) "")
)
((= et "POLYLINE")
(setq e3 (entget (entnext te))
p3 (cdr (assoc 10 e3))
)
(while (/= "SEQEND" (cdr (assoc 0 (setq e4 (entget (entnext
(cdr (assoc -1 e3))) ))) ))
(setq p4 (cdr (assoc 10 e4)))
(if (setq tp (inters p1 p2 p3 p4))
(progn
(command "TRIM" cs "" (list te tp) "")
(setq e4 (entget (entnext (setq te (entlast) )))
p4 (cdr (assoc 10 e4))
)
)
)
(setq e3 e4
p3 p4
)
)
)
((= et "LINE")
(if (setq tp (inters (cdr (assoc 10 ge )) (cdr (assoc 11 ge)) p1 p2))
(command "TRIM" cs "" (list te tp) "")
)
)
)
(setq ic (1+ ic))
)
(grdraw p1 p2 -1 1)
(setq cs nilp1 nilp2 nilts nilge nilic nilte nilet niltp
nilcp nilra nilsa nilea nildv nilma nilia nilp3
nilp4 nild1 nild2 nile3 nile4 nil
)
(princ))